#ifndef NETJOB_H__
#define NETJOB_H__

#include "Interface.h"


class CNetJob : public IRecv
{
public:
	CNetJob();
	virtual ~CNetJob();
	
	virtual void OnContentEncoding(const string& szCoding);
	virtual void OnRecv(char* pBuf,int nLen);
	virtual void OnError(ErrorType nType) ;
	virtual void OnContentLength(int nLen);

	void Init(INetJobMsg* pNetJobMsg);

	const char* GetBuf() const {return m_pBuf;}
	int GetLen() const{return m_nLen;}

	//string GetBufString();
	ErrorType GetError(){return m_nErrType;}

	string GetCoding(){return m_szCoding;}
protected:
	int		m_nTotal;
private:
	char*	m_pBuf;

	int		m_nLen;

	INetJobMsg * m_pNetJobMsg;
	ErrorType m_nErrType;

	string m_szCoding;
};


class CNetFileJob : public CNetJob
{
public:
	CNetFileJob();
	~CNetFileJob();

	virtual void OnContentEncoding(const string& szCoding);
	virtual void OnRecv(char* pBuf,int nLen);
	virtual void OnError(ErrorType nType) ;

	bool Init(INetJobMsg* pNetJobMsg,const CString& strFilePath);

	ErrorType GetError(){return m_nErrType;}

	string GetCoding(){return m_szCoding;}
private:
	INetJobMsg * m_pNetJobMsg;
	ErrorType m_nErrType;

	string m_szCoding;

	CString m_strFilePath;
	CFile m_File;
	int m_nHasRecv;
	
};


#endif